 /*
    *  Copyright 2004 Thevert Liu  <thevert.liu@gmail.com>
    *
    *  Licensed under the Apache License, Version 2.0 (the "License");
    *  you may not use this file except in compliance with the License.
    *  You may obtain a copy of the License at
    *
    *      http://www.apache.org/licenses/LICENSE-2.0
    *
   *  Unless required by applicable law or agreed to in writing, software
  *  distributed under the License is distributed on an "AS IS" BASIS,
   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *  See the License for the specific language governing permissions and
   *  limitations under the License.
   */
#ifndef X2_XMLREADER_H
#define X2_XMLREADER_H

#include <string>

class XMLContext ;

class IXMLReader
{
public:
    IXMLReader(XMLContext* ctxt) : mXMLContext(ctxt) {}

	virtual ~IXMLReader() {}
    virtual bool create(const std::string& xmlbody, const std::string& roottag) = 0 ;
	virtual bool getAttribute(const std::string& name, std::string& val) const = 0 ;
	virtual bool getAttributeNS(const std::string& prefix, const std::string& name, std::string& val) const = 0 ;
    virtual bool getExpandData(std::string& val) const = 0 ;
    virtual bool getValue   (std::string& val) const = 0 ;
    virtual bool nextElement(std::string& name) const = 0 ;
    virtual bool getNSName(std::string& ns, std::string& name) = 0 ;
    virtual int  getTreeStartDepth() const = 0;
    virtual bool getParentName(std::string& name) const = 0 ;
    virtual bool isValue  () const = 0 ;
    virtual bool isElement() const = 0 ;

    bool nextElement(std::string& name, int depth) {return true;};

    void setError(const std::string& error) {mError += error;}

    std::string getError() const {return mError;}
    
    XMLContext * getXMLContext() {return mXMLContext ;}

    void setContext(XMLContext* ctx){mXMLContext = ctx;}

private:
    std::string mError ;
    XMLContext * mXMLContext ;
    
} ;


#endif //X2_XMLREADER_H
